package com.bocloud.cmp.driver.providers.vmware;

import com.bocloud.cmp.driver.providers.AuthDriver;
import com.bocloud.common.model.BsmResult;
import com.vmware.vim25.mo.ServiceInstance;

/**
 * vmware验证接口实现类
 * 
 * @author weiwei
 *
 */
public class VmwareAuthDriver extends VmwareDriver implements AuthDriver {

	/**
	 * 
	 */
	public VmwareAuthDriver() {
		super();
	}

	/**
	 * @param endpoint
	 * @param username
	 * @param password
	 */
	public VmwareAuthDriver(String endpoint, String username, String password) {
		super(endpoint, username, password);
	}

	@Override
	public BsmResult auth() {
		if (this.isAccessable()) {
			ServiceInstance si = this.getServiceInstance();
			// 连接成功之后返回版本信息，对平台版本进行校验
			return new BsmResult(true, si.getAboutInfo().getVersion(), "连接成功");
		} else {
			return new BsmResult(false, "连接失败：地址、用户名或密码输入错误");
		}
	}

}
